1. Field of the Invention
The present invention relates to a network packet receiving management method and related apparatus, and more particularly, to a network packet receiving management method based on an array data structure and an apparatus thereof.
2. Description of the Prior Art
A network interface controller (NIC) provides an identifiable address for an electronic apparatus connecting to a network, and functions as a communication interface between the electronic apparatus and the network. When the electronic apparatus successively receives a network packet from the network, the network interface controller will upload the received network packet to a processing unit within the electronic apparatus, and receive a processed network packet replied by the processing unit. Generally speaking, the data structures adopted by network interface controllers in the present time are mostly linked-list data structures or array data structures. For a received network packet, the linked-list data structure indicates an address of a previous network packet, an address of a next network packet, or both addresses of the previous network packet and the next network packet; in this way, when the processing unit replies packets in an order different from an order used by the network interface controller for uploading packets, the processing unit can still easily find out a sequence of the data arrangement. However, one disadvantage of the linked-list data structure is that it requires more system resource to process and store addresses indicative of a previous and/or a next network packet. On the other hand, the array data structure utilizes a more simplified structure and requires only a little storage space and system resource. The disadvantage of the array data structure is that when the processing unit replies packets in an order different from an order used by the network interface controller for uploading packets, an out-of-order issue will occur, leading to a decrement in interface utilization efficiency.
Please refer to FIG. 1, which is a diagram illustrating an operation of a network packet receiving management method based on an array data structure according to the prior art. An array A1 has four data blocks DB1˜DB4, indicated by four packet descriptors Da1˜Da4, respectively. When the network control interface receives network packets via a network successively, the network packets are stored into the array A1 sequentially; besides, when the data block DB4 indicated by the last packet descriptor Da4 is also occupied by one of the network packets, it will start all over again to store the next network packet in the data block DB1 indicated by the array descriptor Da1. After the array A1 is full with network packets Pa1˜Pa4 and those network packets Pa1˜Pa4 are uploaded sequentially to at least one processor 105, processed network packets Pa1′˜Pa4′ may not be replied in exact the same order in which they are uploaded. For example, the processed network packets are replied to the network interface controller in an order as follows: Pa1′, Pa3′, Pa4′, Pa2′. The network packet Pa1′ is firstly stored in the data block DB1 indicated by the packet descriptor Da1 correctly; nevertheless, since the data block DB2 indicated by the packet descriptor Da2 is for storing the network packet Pa2′, even the processed network packets Pa3′ and Pa4′ are already stored in a buffer unit 110, those processed network packets Pa3′ and Pa4′ are not stored in the data blocks DB3 and DB4 indicated by the array descriptors Da3 and Da4, respectively, until the processed network packet Pa2′ is successively received and stored in the data block DB2. In this example, the network packet Pa2′, which is not replied in order, causes a bubble in the receiving mechanism, leading to degradation in overall receiving efficiency.